﻿<%@ Application Language="C#" %>
<%@ Import Namespace="Twipler.App"%>
<%@ Import Namespace="Twipler.App.Session"%>
<%@ Import Namespace="Twipler.Data.Session"%>
<%@ Import Namespace="System.Threading"%>

<script runat="server">

    void Application_Start(object sender, EventArgs e) 
    {
        log4net.Config.XmlConfigurator.Configure();
        log4net.ILog log = log4net.LogManager.GetLogger(this.GetType());
        log.WarnFormat("Application Start at {0}", DateTime.Now);
    }

    void Application_End(object sender, EventArgs e) 
    {
        log4net.ILog log = log4net.LogManager.GetLogger(this.GetType());
        log.WarnFormat("Application End at {0}", DateTime.Now);        
    }
    
    /*  * /
    void Application_Error(object sender, EventArgs e) 
    {
        Exception ex = Server.GetLastError();
        if (ex == null)
            return;

        Twipler.WebApp.ExceptionReport.Report(ex);
        
        ex = ex.GetBaseException();
        if (ex == null)
            return;
        
        Server.ClearError();
        
        Current.Log.Fatal("Exception: " + ex.Message);             
        Response.Redirect("~/error.aspx");   
    }
    // */
    
    void Session_Start(object sender, EventArgs e) 
    {
        Current.Log.Warn(string.Format("Session Start IP:{0} Request:{1}", Request.ServerVariables["REMOTE_ADDR"], Request.RawUrl));
    }

    void Session_End(object sender, EventArgs e) 
    {
        InnerSessionFactory.Delete(Session.SessionID);
		Current.Log.Warn("Session End ");
    }
       
</script>
